-
Notifications
You must be signed in to change notification settings - Fork 13.5k
mbe: Rework diagnostics for metavariable expressions #142950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There are changes to the cc @jieyouxu |
I split the nonfunctional changes here to a new PR, #143245. I think this should make it a bit more straightforward to do the other changes here. |
…ation, r=petrochenkov mbe: Add tests and restructure metavariable expressions Add tests that show better diagnostics, and factor `concat` handling to a separate function. Each commit message has further details. This performs the nonfunctional perparation for further changes such as rust-lang#142950 and rust-lang#142975 .
@rustbot author |
Reminder, once the PR becomes ready for a review, use |
Rollup merge of #143245 - tgross35:metavariable-expr-organization, r=petrochenkov mbe: Add tests and restructure metavariable expressions Add tests that show better diagnostics, and factor `concat` handling to a separate function. Each commit message has further details. This performs the nonfunctional perparation for further changes such as #142950 and #142975 .
This comment was marked as resolved.
This comment was marked as resolved.
51693ef
to
1146773
Compare
This comment has been minimized.
This comment has been minimized.
13a7e49
to
7e5760b
Compare
7e5760b
to
5366b37
Compare
5366b37
to
b276ff8
Compare
} | ||
|
||
/// Map of `(name, max_arg_count, variable_count)`. | ||
const EXPR_NAME_ARG_MAP: &[(&str, ArgSpec)] = &[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only used once, probably better to turn it into a match
on strings.
]; | ||
|
||
/// List of the above for diagnostics | ||
const VALID_METAVAR_EXPR_NAMES: &str = "`count`, `ignore`, `index`, `len`, and `concat`"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also only used once.
r=me with the comments addressed. |
Give a more user-friendly diagnostic about the following: * Trailing tokens within braces, e.g. `${foo() extra}` * Missing parentheses, e.g. `${foo}` * Incorrect number of arguments, with a hint about correct usage.
Change to a structural diagnostic, update the valid list, and move the valid list to a note.
b276ff8
to
dff37db
Compare
Make the diagnostics for metavariable expressions more user-friendly. This mostly addresses syntactic errors; I will be following up with improvements to
concat(..)
.r? @petrochenkov